
//ie polyfill 兼容9+
import './polyfill';
import 'core-js/es';
import 'mutation-observer';
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

import '@/less/index.less';
import '@/services/axios-config';
import { ActionSheet, Modal, Toast } from 'antd-mobile-v2';
import * as serviceWorker from './serviceWorker';
import RouteConfig from './router';

import { updateDocumentTitle } from '@/utils/document-title';

import { Provider } from 'react-redux';
import { store } from '@/redux';
import history from './utils/history';
// import VConsole from 'vconsole';

// 开发环境和测试环境打开VConsole
// const isDevOrSit = process.env.REACT_APP_ENV.includes('dev') || process.env.REACT_APP_ENV.includes('sit');
// if (isDevOrSit) new VConsole();

// Toast全局设置
Toast.config({
  duration: 2, //保持显示2秒
  mask: false // 取消蒙层，允许弹出toast的时候进行其他操作
});

history.listen(() => {
  ActionSheet.close(); //路由变化就销毁操作列
  Modal.alert().close(); //路由变化就销毁弹窗
});

updateDocumentTitle(document.title);

ReactDOM.render(
  <Provider store={store}>
    <RouteConfig />
  </Provider>,
  document.getElementById('root')
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();